package tech.senri.iot.socket.controller

import com.fasterxml.jackson.databind.ObjectMapper
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.redis.core.StringRedisTemplate
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import tech.senri.iot.socket.config.RedisMQConfig
import tech.senri.iot.socket.model.*
import tech.senri.iot.socket.service.socket.SessionManager

@RestController
@RequestMapping("/api")
@Api(tags = ["智大通讯协议"])
class SocketTestResource
{
    @Autowired
    private lateinit var template: StringRedisTemplate

    @Autowired
    private lateinit var objectMapper: ObjectMapper

    @PostMapping("/updatePriceInventoryRequest")
    @ApiOperation("下发设置价格、库存")
    fun updatePriceInventoryRequest(@RequestBody vm: UpdatePriceInventoryRequest): UpdatePriceInventoryResponse
    {
        template.convertAndSend(RedisMQConfig.device_message_request,objectMapper.writeValueAsString(vm))
        return UpdatePriceInventoryResponse()
    }

    @PostMapping("/UpdateAislesCapacityRequest")
    @ApiOperation("服务器下发货道容量")
    fun updateAislesCapacityResponse(@RequestBody vm: UpdateAislesCapacityRequest): UpdateAislesCapacityResponse
    {
        TODO()
    }

    @PostMapping("/UpdateDiscountRequest")
    @ApiOperation("商品打折设置")
    fun updateDiscountResponse(@RequestBody vm: UpdateDiscountRequest): UpdateDiscountResponse
    {
        TODO()
    }

    @PostMapping("/UpdateMergeAisleRequest")
    @ApiOperation("合并货道设置")
    fun updateMergeAisleResponse(@RequestBody vm: UpdateMergeAisleRequest): UpdateMergeAisleResponse
    {
        TODO()
    }

    @PostMapping("/DeviceStateConfirmRequest")
    @ApiOperation("板卡实时状态数据上报")
    fun deviceStateConfirmRequest(@RequestBody vm: DeviceStateResponse): DeviceStateConfirmRequest
    {
        TODO()
    }

    @PostMapping("/SimStateConfirmRequest")
    @ApiOperation("SIM 卡 ICCID 上报帧")
    fun simStateConfirmRequest(@RequestBody vm: SimStateResponse): SimStateConfirmRequest
    {
        TODO()
    }

    @PostMapping("/DiscountAmountConfirmRequest")
    @ApiOperation("打折金额上报")
    fun amountConfirmRequest(@RequestBody vm: DiscountAmountResponse): DiscountAmountConfirmRequest
    {
        TODO()
    }

    @PostMapping("/AislesCapacityConfirmRequest")
    @ApiOperation("实时货道容量数据上传")
    fun capacityConfirmRequest(@RequestBody vm: AislesCapacityResponse): AislesCapacityConfirmRequest
    {
        TODO()
    }

    @PostMapping("/DeliverCommodityRequest")
    @ApiOperation("主动出货请求")
    fun commodityResponse(@RequestBody vm: DeliverCommodityRequest): DeliverCommodityResponse
    {
       template.convertAndSend(RedisMQConfig.device_message_request,objectMapper.writeValueAsString(vm))
        return DeliverCommodityResponse()
    }

    @PostMapping("/RemoteTestRequest")
    @ApiOperation("远程测试")
    fun RemoteTestRequest(@RequestBody vm: RemoteTestRequest): String
    {
        TODO()
    }

    @PostMapping("/ScanQRCodeInfoResponse")
    @ApiOperation("扫码信息上传")
    fun ScanQRCodeInfoResponse(@RequestBody vm: ScanQRCodeInfoResponse): String
    {
        TODO()
    }

    @PostMapping("/SaleDataResponse")
    @ApiOperation("收款/退款数据上报")
    fun SaleDataResponse(@RequestBody vm: SaleDataResponse): SaleDataConfirmRequest
    {
        TODO()
    }

}
